#include<SFML\Graphics.hpp>

class MultiPassRenderer: sf::Drawable
{
private:
	struct{
		sf::Shader* shader;
		int passAmount;
		bool hasTexture;
	} _shaders[10];

	int _nbShaders = 0;

	struct RenderBuffer{
		sf::RenderTexture* renderTexture;
		sf::Sprite* sprite;
	} _buffers[2];

	const sf::Texture* _startingTexture;
	sf::Sprite* _startingSprite;
	//sf::RenderTarget* _finaleRenderTarget = NULL;
	//sf::RenderTexture* _finaleRenderTarget = NULL;

	void initializeRenderBuffer(RenderBuffer& renderBuffer);
	void createRenderBuffer(RenderBuffer& renderBuffer, unsigned int width, unsigned int heigh);
	void clearShaders();

public:
	MultiPassRenderer();
	~MultiPassRenderer();
	void create(unsigned int width, unsigned int heigh);

	MultiPassRenderer& startWith(const sf::Texture& texture, bool clearShaderStack = true);
	MultiPassRenderer& continueWith(sf::Shader& shader, int passAmount = 1, bool hasTexture = true);
	bool endWith(sf::RenderTexture& renderTarget);
	virtual void draw(sf::RenderTarget& target, sf::RenderStates states = sf::RenderStates::Default) const;
};